from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
testCase = "DBshop031"
firefox =openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,'商品管理','商品标签','特定商品标签')

# 1.点击“编辑”按钮，标签类型“手机端首页商品”，标签名称“1F商品”。
firefox.find_element_by_xpath('//td[contains(text(),"1F商品")][1]/following-sibling::td[3]/a[1]').click()
s= Select(firefox.find_element_by_id('tag_type'))
s.select_by_visible_text('手机端首页商品')
# 2.点击“保存标签信息按钮”，保存成功。
firefox.find_element_by_xpath('//button[contains(.,"保存标签信息")]').click()

try:
    firefox.find_element_by_xpath('//td[contains(text(),"1F商品")][2]').text=="手机端首页商品"
    writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)

firefox.quit()